Yea, just recently I enrolled into a basic computer programming class. We use Turbo Visual C++ and umm so far it went okay until we talked about do-for-while loops... Can anyone help in making a program in loops >_< I mean I tried using the goto statements but my professor doesn't want that in the statement T_T..
Basically the assignment or problem was to make a multiple choice program.. A) would display info B) would take info C) would shut it down.. I pretty much got displaying and taking and shutting it down part.. but.. When it came to the option of "Would you like to go back to the main menu" after you chose either A or B.. I got so confused >_<... I tried using switch and if statements cause I didnt' ahve a full understanding of do-for-while..
Another side assignment was the Fabonnaci code or something.. I know this uses the for statement.. supposedly the first two numbers in the statement are 1.. not counting zero and the next numbers take the previous two numbers and add them.. so the 3rd would be 2.. 4th would be 3.. 5th.. being 5.. etc.. I tried using the for statement but I'm not sure how to program such a problem..
I know it seems like too much but everywhere I look i see cout and cin when I use printf and scanf @_@, Please anyone help me.. I don't know where else to look
#include<stdio.h>
#include<conio.h>
char choice[2], restart;
int d,i;
main()
{
printf("Options:\n");
printf("\ta. Introduction.\n");
printf("\tb. Display the Fibonacci set.\n");
printf("\tc. EXIT the program.\n");
printf("\nChoose a letter: ");
scanf("%c", &choice[2]);
switch (choice[2]) {
case 'A':
case 'a':
printf("\n\n\tThe Fibonacci numbers are numbers of");
printf("\n\tan interesting sequence in which each");
printf("\n\tnumber is equal to the sum of the");
printf("\n\tprevious two numbers. In other words.");
printf("\n\t\tFi = (Fi-1)+(Fi-2)");
printf("\n\t\tWhere Fi refers to the ith Fibonacci number.");
printf("\n\t\tBy definintion F1 = F2 = 1");
printf("\n\t\tHence:\tF3 = F2 + F1 = 2");
printf("\n\t\t\tF4 = F3 + F2 = 3");
printf("\n\t\t\tF5 = F4 + F3 = 5");
break;
case 'B':
case 'b':
printf("\nPlease enter how many Fibonacci numbers to be displayed:
");
scanf("%i",&d);
if (d = 0);
printf("Please enter higher than zero.");
if (d = 1);
printf("\n 1");
if (d = 3){
i = 3;
while (i < d) {
printf("%3i",i = (i-1) + (i-2));
i++;
}
}
break;
case 'C':
case 'c':
break;
}
getch();
}
This is what I was working on.. It looks so wrong and it's a disadvantage not having the actual program >_< And sorry this is my first post so I don't know if I posted this problem right