Courses

### Courses

Structure and Union

No Examples found for this topic - CodeHelpPro

Data Files

No Examples found for this topic - CodeHelpPro

# Effective way to take input from user

0 Suresh Chand June 2, 2021

In this program, We will take input from user and display it on the screen. To understand this knowledge, You must have knowledge in following topics

Here we have used some basic inbuilt-functions of C program.

• printf() – Used to print the string on the screen
• & – Denotes the address of a variable. We will use this to store the value to the particular address of variable
• scanf() – Used to take input from standard input
• %d and %i are used to identifying the integer values.
• %f are used to identify the float or fractional values
• %c are used to identify the character values

## Algorithm

In this algorithm, We will only take integer input and print that integer values only.

```Step 1 : Start
Step 2: Declare integer variables as num1 and num2.
Step 3: Take input from the user and store it in num1 and num2
Step 4: Print num1 and num2
Step 5: End```

## Code to take input from user

``````#include<stdio.h>

int main()
{
printf("\n\n\tLearn Programming with Codehelppro\n\n\n");

int num1, num2;
float fraction;
char character;

printf("Enter two numbers number : \n");

// Taking integer as input from user
scanf("%d%i", &num1, &num2);
printf("\n\nThe two integer numbers that have entered : %d and %i\n\n", num1, num2);

// Taking float or fraction as input from the user
printf("\n\nEnter a Decimal number : \n");
scanf("%f", &fraction);
printf("\n\nThe float or fraction number that you have entered : %f", fraction);

// Taking Character as input from the user
printf("\n\nEnter a Character : \n");
scanf("%c", &character);
printf("\n\nThe character that you have entered : %c", character);

return 0;
}``````

The output of above program is

If you feel any issue, Please feel free to comment below. You can also contribute your example to us. We

Subscribe
Notify of
Inline Feedbacks

Get the latest tutorials, examples and projects updates.

!