If 4 digits number is input through the keyboard, Write a
program to calculate sum of its 1st & 4th digit.

Answer Posted / akhiltelaprolu

#include<stdio.h>
main()
{
int n,a[20],b[20],i,j;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
for(j=0;j<n/2;j++)
{
b[j]=a[i]+a[n-1];
i++;
n=n-1;
}
for(j=0;j<n/2;j++)
printf("%d",b[j]);
if(n%2!=0)
printf("%d",a[n/2]):
}

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where static variables are stored in memory in c?

527


What is output redirection?

698


What is function and its example?

630


How do I use strcmp?

645


Array is an lvalue or not?

642






write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

2457


Why isnt there a numbered, multi-level break statement to break out

592


Why we use void main in c?

599


What are the storage classes in C?

629


main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }

925


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

605


What is the use of #include in c?

585


Explain what is the benefit of using enum to declare a constant?

593


‎How to define structures? · ‎

636


What is 1d array in c?

602