Skip to content

Commit 2efcb94

Browse files
committed
Adding scanning.c
1 parent 7f0f2fb commit 2efcb94

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

scanning.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
int grade;
6+
char firstInit;
7+
char secondInit;
8+
double yearsOld;
9+
10+
printf("Please input your first initial and press \"Enter\"\n"); //Note that \" lets your print a backslash
11+
scanf("%c",&firstInit); //scans and stores the character input
12+
getchar(); //gets rid of the "enter" character
13+
printf("Please input your second initial and press \"Enter\"\n");
14+
scanf("%c",&secondInit);
15+
getchar();
16+
17+
printf("Please input what grade you got on your last test (0-100) and press \"Enter\"\n");
18+
scanf("%d",&grade);
19+
20+
printf("Please input how old you are in years (including decimals. E.G 3.4) and press \"Enter\"\n");
21+
scanf("%lf",&yearsOld);
22+
23+
printf("My initials are %c.%c . My most recent grade was a %d and I am currently %.1lf years old\n",firstInit,secondInit,grade,yearsOld); //Note that .1 before the lf will esure that only one decimal place is printed
24+
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)