CheeseKao
Lord Cheesington
I'm trying to split a number with n digits into n numbers and add them up. For example: I type in 29 and I need a method to get the sum of 2 and 9.
#include <stdio.h>
int main(int argc, char *argv[])
{
int year[3],S4;
printf("Enter your year of birth: ");
scanf("%d", year);
S4=year[0];
printf("%d", S4);
return 0;
}
I tried doing this but when I type a number like 1990, it outputs 1990 instead of 1. Do note that I am a beginner and I don't really know any advanced functions and such. Any help is very much appreciated.
#include <stdio.h>
int main(int argc, char *argv[])
{
int year[3],S4;
printf("Enter your year of birth: ");
scanf("%d", year);
S4=year[0];
printf("%d", S4);
return 0;
}
I tried doing this but when I type a number like 1990, it outputs 1990 instead of 1. Do note that I am a beginner and I don't really know any advanced functions and such. Any help is very much appreciated.