scanf() is an input function.
It takes an input from the user and store it in a variable.
Since "&" is a reference operator and it represents the memory location of the variable.
String is a type of array and an array consumes more than one memory address.
It is obvious that no need to use "&" operator for an entire array.
For an individual data type like int , char , float etc , "&" is needed but for an array no need to use "&".
#include void main() { int i=2,m,n; printf("enter number"); scanf("%d",&n); do { m=i*n; printf("%d*%d=%d\n",n,i,m); i=i+1; } while (i<=10); }
int i, largest=0;do { scanf ("Enter a number (0 to exit): %d", i); if (i>largest) largest=i; } while (i!=0); printf ("Largest number is: %d\n", largest);
#include<stdio.h> main() { int a,i=1; printf("Enter max no"); scanf("%d",&a); do { printf("%d",i); i=i+2; }while(i<=a); }
#include <stdio.h> main() { FILE *a; int sno,tm,em,mm,scm,sm,hm; char sname[20],any[1]; clrscr(); a=fopen("student.dat","a"); do { printf("Enter Student Number : "); scanf("%d",&sno); printf("Enter Student Name : "); scanf("%s",sname); printf("Enter Telugu Marks : "); scanf("%d",&tm); printf("Enter English Marks : "); scanf("%d",&em); printf("Enter Maths Marks : "); scanf("%d",&mm); printf("Enter Science Marks : "); scanf("%d",&scm); printf("Enter Social Marks : "); scanf("%d",&sm); printf("Enter Hindi Marks : "); scanf("%d",&hm); fprintf(a,"%d %s %d %d %d %d %d %d\n",sno,sname,tm,em,mm,scm,sm,hm); printf("Do you wish to continue(Y/N)"); scanf("%s",any); }while(strcmp(any,"y")==0); fclose(a); }
In C we use & operator while giving address of some variable to some pointer variable. & operator is also used in scanf().
#includevoid main(){char str1[10],str2[10];int i=0;int flag = 0;printf("enter first string\n");scanf("%s",str1);printf("enter second string\n");scanf("%s",str2);while(str1[i]!='/0' && str2[i]!='/0'){if(str1[i]!=str2[i])flag=1;if(flag==1){printf("not equal\n");break;}if (flag==0){printf("equal\n");break;}}}
do statement; while (condition);ordo { statements } while (condition);
mystrcpy (char* dest, char* src) { while ((*dest++ = *src++) != '\0); }
%c and %s are format characters used for input and output. These are mainly used in scanf and printf statements. %c is used for characters while %s is used for strings. For input, it is used to specify the type of the value to be read while for output, it is used to specify the type of the value to be printed.
There are two different kind of strings. There are nylon strings and steel strings. Nylon strings are found on acoustic guitars while steel strings are common to find on electronic guitars.
By plucking the strings, drawing the bow acros the strings while fingering the frets.
#include void main() { int i=2,m,n; printf("enter number"); scanf("%d",&n); do { m=i*n; printf("%d*%d=%d\n",n,i,m); i=i+1; } while (i<=10); }
There are no hollow core squash racket strings, though they do exist for tennis. There are two main types of string design in strings used for squash: monofilament & multifilament. Monofilament strings are a single solid material while multifilament strings are braided and have no central core. Monofilament strings tend to be more durable but typically transfer more shock to the arm while multifilament strings have a softer feel at impact and are closer in playability to natural gut.
#include<stdio.h> int main(){ intnum,i,count,min,max; printf("Enter min range: "); scanf("%d",&min); printf("Enter max range: "); scanf("%d",&max); num = min; while(num<=max){ count = 0; i=2; while(i<=num/2){ if(num%i==0){ count++; break; } i++; } if(count==0 && num!= 1) printf("%d ",num); num++; } return 0; }
the ham strings
#include<stdio.h> #include<conio.h> void main() { int no, ans; clrscr(); printf(input no. \n"); scanf("%d", &no); while(no!=0) { n=no%10; no=no/10; printf("%d",n); } getch(); }
int i, largest=0;do { scanf ("Enter a number (0 to exit): %d", i); if (i>largest) largest=i; } while (i!=0); printf ("Largest number is: %d\n", largest);