print numbers with DO WHILE loop in C Get link Facebook X Pinterest Email Other Apps March 25, 2021 #include<stdio.h>int main(){ int i=0; int n; printf("Enter the value of n\n"); scanf("%d", &n); do{ printf("The number is %d\n",i); i++; } while(i<n); return 0;} Get link Facebook X Pinterest Email Other Apps Comments
create a num table in a new file in c May 06, 2021 #include<stdio.h> int main() { FILE *ptr; int num; printf("Enter the integer which table you need of\n"); scanf("%d",&num); ptr = fopen("table.txt","w"); for(int i=0 ; i<10 ; i++){ fprintf(ptr,"%d*%d=%d\n",num,i+1,num*(i+1)); } fclose(ptr); return 0; } Read more
write a programme to compare time stamp in c April 28, 2021 #include<stdio.h> #include<string.h> typedef struct time_stamp{ int year; int month; int date; int hour; int minute; int seacond; }time_stamp; void display(time_stamp dt1,time_stamp dt2){ printf("the time stamp is: %d/%d/%d-%d:%d:%d\n",dt1.year,dt1.month,dt1.date,dt1.hour,dt1.minute,dt1.seacond); //} //void display(time_stamp dt2){ printf("the time stamp is: %d/%d/%d-%d:%d:%d\n",dt2.year,dt2.month,dt2.date,dt2.hour,dt2.minute,dt2.seacond); } int time_stampcmp(time_stamp dt1,time_stamp dt2){ if(dt1.hour>dt2.hour){ return 1; } if(dt1.hour<dt2.hour){ return -1; } if(dt1.minute>dt2.minute){ return 1; } if(dt1.minute<dt2.minute){ return -1; } if(dt1.seacond>dt2.seacond){ return 1; } if(dt1.seacond<dt2.seacond){ return -1; } if(dt1.year>dt2.year){ return 1; } if(dt1.year<dt2.year){ return -1; } if(dt1.month>dt2.month){ return 1; } if(d... Read more
creating snake , water , gun game in c May 09, 2021 #include<stdio.h> #include<stdlib.h> #include<time.h> int SnakeWaterGun(char you , char comp){ if(you == comp){ return 0; } if(you=='s' && comp=='g'){ return -1; } else if(you=='g' && comp=='s'){ return 1; } if(you=='s' && comp=='w'){ return 1; } else if(you=='w' && comp=='s'){ return -1; } if(you=='g' && comp=='w'){ return -1; } else if(you=='w' && comp=='g'){ return 1; } } int main() { char you,comp; srand(time(0)); int number = rand()%100+1; if(number<33){ comp = 's'; } else if(number>33 && number<66){ comp = 'w'; } else if(number<66){ comp = 'g'; } printf("Enter 's' for snake , 'g' for gun , 'w' for water\n"); scanf("%c",&you); int result = SnakeWaterG... Read more
Comments
Post a Comment