Nested For Loop in C with Examples
Loops allow us to repeatedly execute code in an efficient manner. They form an integral part of programming across languages. In C, we have tools like the humble for loop to perform repetitive tasks....
Loops allow us to repeatedly execute code in an efficient manner. They form an integral part of programming across languages. In C, we have tools like the humble for loop to perform repetitive tasks....
Program 1 //Diffrence between malloc and calloc function for Dynamic memory #include<stdio.h> #include<stdlib.h> #include<conio.h> void main() { int *ar,n,i; printf(“%d”,sizeof(int)); printf(“Enter the limit”); scanf(“%d”,&n); ar= (int*)calloc(sizeof(int),n); // n block of 4 size printf(“Enter elements...
Program 1 #include<stdio.h> #include<conio.h> #include<stdlib.h> // Declaration of function void dtobin(); void design(); void dtooct(); void dtohexa(); void bintodec(); void bintooct(); void bintohexa(); //Defination of main int main() { system(“cls”); design(); } //Defination of...
Program 1 // Program for Binary to decimal and decimal to octal #include<stdio.h> #include<conio.h> #define clrscr() system(“cls”) int main() { int n,dn=0,r,b=1,binary,i=0,ar[50]; clrscr(); printf(“Enter a binary number( only 0 and 1 format)”); scanf(“%d”,&n); binary=n;...
Program 1 // Program for Binary to hexa decimal #include<stdio.h> #include<conio.h> #define clrscr() system(“cls”) int main() { int n,dn=0,r,b=1,binary,i=0,ar[50]; clrscr(); printf(“Enter a binary number( only 0 and 1 format)”); scanf(“%d”,&n); binary=n; while(n!=0) { r=n%10;...
Program 1 // Program for Binary to decimal and decimal to octal #include<stdio.h> #include<conio.h> #define clrscr() system(“cls”) int main() { int n,dn=0,r,b=1,binary,i=0,ar[50]; clrscr(); printf(“Enter a binary number( only 0 and 1 format)”); scanf(“%d”,&n); binary=n;...
Program 1 // coin toss application #include<stdio.h> #include<conio.h> #include<stdlib.h> #include<time.h> #define clrscr() system(“cls”) int main() { int n; clrscr(); srand(time(NULL)); n=rand()%10; // printf(“%d”,n); if(n>5) printf(“*****head*****”); else printf(“*****tail******”); }
Program 1 #include<stdio.h> #define clrscr() system(“cls”) int main() { int i; char ch; clrscr(); printf(“\n Character \t Ascii Values”); for(i=0;i<=255;i++) { ch=i; // implicit type conversion printf(“\n%c\t %d”,ch,i); } return 0; }
Program 1 #include<stdio.h> #include<conio.h> #include<stdlib.h> int main() { int me,you,count=5,i=1,f=0; system(“cls”); srand(time(NULL)); me=rand()%100; //printf(“%d”,me); while(i<=5) { printf(“\n Enter a number for guess.. you left %d chance”,count); scanf(“%d”,&you); if(me==you) { printf(“\n\nGreat… You win game is...
Program 1 #include<stdio.h> #include<conio.h> #include<time.h> int main() { int n,i,l,u; system(“cls”); srand(time(NULL)); printf(“Enter lower value of Random Number”); scanf(“%d”,&l); printf(“Enter upper value of Random Number”); scanf(“%d”,&u); for(i=1;i<=5;i++) { n=(rand() %(u-l+1)) + l; printf(“%5d”,n); }...