Answer:
#include <stdio.h>
#include <string.h>
int main(){
char number[100];
printf("Number: ");
scanf("%s", number);
int sum = 0;
for(int i =0;i<strlen(number);i++){
sum+= number[i] - '0';
}
printf("Sum: %d",sum);
return 0;
}
Explanation:
This declares a c string of 100 characters
char number[100];
This prompts user for input
printf("Number: ");
This gets user input
scanf("%s", number);
This initializes sum to 0
int sum = 0;
This iterates through the input string
for(int i =0;i<strlen(number);i++){
This adds individual digits
sum+= number[i] - '0';
}
This prints the calculated sum
printf("Sum: %d",sum);
return 0;
Storing music files on a smartphone in order to maximize the number of
songs that can be stored is most appropriate for choosing lossy
compression over lossless compression.
<h3>What is Lossy compression?</h3>
Lossy compression refers to a type of data compression which results in
the file size being small. Most times the quality is reduced as a result of
this .
This gives rise to more space being made available for the storage of more
song files which is why it is most appropriate.
Read more about Lossy compression here brainly.com/question/18806025
Answer:
create the integer variable and initialize it to one, with the do statement, increment the variable by one and print it, then the while statement checks if the variable is less than or equal to 10.
#include <iostream>
using namespace std;
int main(){
int i = 1;
do {
cout<< i << "\n";
i++;
}
while (i <= 10);
}
Explanation:
The C++ source code initializes the integer variable i to one and increments and print the value if the value is less than or equal to ten. The do-while statement executes a block of code before the condition is implemented.
the opening tag for an HTML document