#include<stdio.h> #include<string.h> int main(){ struct fruits{ char name[20]; float rate; int quantity; }; struct fruits fruit1,fruit2; strcpy(fruit1.name ," apple"); fruit1.rate= 5.10; fruit1.quantity= 200; strcpy(fruit2.name ," banana"); fruit2.rate= 10.10; fruit2.quantity= 100; printf("name of fruit is = %s \n",fruit1.name); printf("rate of fruit is = Rs.%.2f \n",fruit1.rate); printf("quantity of fruit is = %d \n",fruit1.quantity); printf("name of fruit is = %s \n",fruit2.name); printf("rate of fruit is = Rs.%.2f \n",fruit2.rate); printf("quantity of fruit is = %d \n",fruit2.quantity); }
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> int randomnum; int userinput; void generate() { srand(time(NULL)); randomnum = 1 + rand() % 10; } void welcomemeg() { printf("welcome to number guessing game \n"); printf("type number between 1-10\n>>"); generate(); scanf("%d", &userinput); } int main() { bool isgameover = false; welcomemeg(); while(! isgameover) { if (userinput < randomnum) { printf("try some thing big\n"); scanf("%d", &userinput); } else if (userinput > randomnum) { printf("try some thing small\n"); scanf("%d", &userinput); } else { printf("you won the game\n"); printf("try again by typing y or just click enter to exit\n"); getchar(); char userchoice; char y; scanf("%c",&y); userchoice = getchar(); ...
Comments
Post a Comment