Date: 22-OCT-2014
The Last Program An Error Was Occured/showned.
Error Was Shown In This Program/Coding.
#include<stdio.h>
#include<conio.h>
void main()
{
int marks;
char result;
clrscr();
printf("Enter student marks\n");
scanf("%d",&marks);
printf("enter student result\n");
scanf("%c",&result);
printf("student marks=%d\n",marks);
printf("student result=%c",result);
getch();
}
OUTPUT SCREENSHOT IN ERROR
Here Is The Program/Coding Which Have No Error, Same As Above.
#include <stdio.h>
#include <conio.h>
int main()
{
int marks;
char result;
clrscr();
printf("Enter student marks\n");
scanf("%d",&marks);
printf("enter student result\n");
scanf(" %c",&result); //here was the error
printf("student marks=%d\n",marks);
printf("student result=%c",result);
getch();
return 0;
}
OUTPUT SCREENSHOT
Solution:
Just Add Space Before %C in Scanf Syntax when declaring Character.(can also add before %d, %f etc)
<3 RAHEEL <3