Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Sunday, July 10, 2022

C program to calculate sum of input 4 digits number for SEE and NEB

 C program to calculate sum of input 4 digits number for SEE and NEB



Introduction


In this post, we are going to learn how to write C program to calculate sum of input 4 digits number for SEE and NEB. In several situations, including SEE (Secondary Education Examination) and NEB (National Examinations Board), we will examine the program's goal and significance.

Understanding the Problem Statement


The task demands us to determine the 4-digit number's digit sum. For instance, the software should determine the total as 1 + 2 + 3 + 4 = 10 if the user provides the number 1234.

Example


Let's think about an example and go through the program's execution to help you better understand the idea. We'll give an example input, walk you through the computation, and show you the results. The functionality of the software will be demonstrated by use of this example.




/*Sum of individual 4 digits*/

#include<stdio.h>

#include<conio.h>

void main()

{

int num,first,second,third,fourth,sum;

clrscr();

printf("\nInput 4 Digited Number:- ");

scanf("%d",&num);

first=num%10;

num=num/10;

second=num%10;

num=num/10;

third=num%10;

num=num/10;

fourth=num%10;

num=num/10;

sum=first+second+third+fourth;

printf("\nSum = %d",sum);

getch();


}



Output:



Conclusion


In this article, we learned how to write a C program to calculate sum of input 4 digits number for SEE and NEB. Students studying for the Nepal SEE and NEB exams may find this program helpful. Users can quickly determine the sum of the digits in a given 4-digit number by following the instructions and putting the program into action.


No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages