Write a program using Visual Studio 2017 that accepts four (4) lines of input:
• The first line contains a float value in 4.2f format • The second line contains a char value
• The third line contains a 4-digit int value
• The fourth line contains a char value and then displays all of the input on a single line
Phone Number
Write a program that accepts a phone number of the form +1(xxx)-xxxxxxx where x is a digit, and displays the sum of all digits (x's) in the phone number.
SUBMIT BOTH PIECES IN ONE FILE LAB2.C
Please find both the pieces in C program below:-
#include<stdio.h>
#include<conio.h>
void displaySum(char phone[]){
int n1 = phone[3] - '0';
int n2 = phone[4] - '0';
int n3 = phone[5] - '0';
int n4 = phone[8] - '0';
int n5 = phone[9] - '0';
int n6 = phone[10] - '0';
int n7 = phone[11] - '0';
int n8 = phone[12] - '0';
int n9 = phone[13] - '0';
int n10 = phone[14] - '0';
int sum = n1 + n2+n3+n4+n5+n6+n7+n8+n9+n10;
printf("sum of all digits (x's) in the phone number: %d\n", sum);
}
int main(int argc, char* argv[]){
system("cls");
char phone[20];
float f1 = 4.2f;
char c1 = 'A';
int i = 1234;
char c2 = 'Z';
printf("\n%.2f %c %d %c", f1, c1, i, c2);
printf("\nEnter Mobile Number in the format(+1(xxx)-xxxxxxx): ");
scanf("%s", &phone);
displaySum(phone);
system("PAUSE");
return 0;
}
The output is attached below:-
Please let me know in case of any clarifications required. Thanks!
Write a program using Visual Studio 2017 that accepts four (4) lines of input: • The...
Write a C program that accepts a phone number of the form +1(xxx)-xxx-xxxx where x is a digit, and displays the sum of all digits in the phone number.
Create a program using Visual Studio 2017 called dataExercise.c that declares the following variables and displays their values: 1. Declare a character variable with value 'a', and display the character using printf with a %c format. Then add a second printf that displays the character with a %d format. 2. Declare a short int variable with a value set to the maximum value of a short int (the maximum value for whatever machine I happen to use to grade your...
In c++ visual studio Write a program that does the following: Reads the input data set from file named "data.txt". Assume that the input file contains x and y values as shown in the sample to the right (the first number in each line is the x value). The number of data points in the input file is not known but assume that they will not exceed 100. Once it gets the data in two one-dimensional arrays (x and y),...
This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.11 Lab Exercise Ch.6a: Functions: String analyzer Create and debug this program in Visual Studio. Upload your Source.cpp file for testing (1) Prompt the user to enter a string of their choosing. Output the string. (1 pt) Ex: ics Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have...
using c# visual studio 3.28 (Digits of an Integer) Write an app that inputs one number consisting of five digits from the user, separates the number into its individual digits and displays the digits separated from one another by three spaces each. For example, if the user types 42339, the app should display 4 2 3 3 9 Assume that the user enters the correct number of digits. What happens when you execute the app and type a number with...
My C++ program is not compiling. Please explain how you fixed with detailed inline comments. I am using Visual Studio 2017. It's a character count program that keeps and displays a count of all the upper, lower case and digits in a .txt file. The requirement is to use classes to implement it. -----------------------------------------------------------------HEADER FILE - Text.h--------------------------------------------------------------------------------------------- /* Header file contains only the class declarations and method prototypes. Comple class definitions will be in the class file.*/ #ifndef TEXT_H #define...
2) Write a C++ (using visual studio) program that display the following information, each on a separate line a. your name b. c. your college major
C++ programing (Visual Studio) Write a program to convert a Decimal number of any value inputted by the user to a Type_4 number. Type_4 definitions: This number just have 4 digits: 0,1, 2, 3 Example: Decimal: 15 25/4 = 6 6/4 = 1 1/4 = 0 25% 4 = 1 6% 4 = 2 1% 4 = 1 Type_4 = 121
This program should be run on Visual Studio. Please use printf and scanf as input and output. Thank you 6.12 Lab Exercise Ch.6b: C-string functions Create and debug this program in Visual Studio. Name your code Source.c and upload for testing by zyLabs You will write 2 functions which resemble functions in the cstring library. But they will be your own versions 1. int cstrcat(char dstDchar src) which concatenates the char array srcl to char array dstD, and returns the...
build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and 9 inclusively. If so, the digit will be stored as the next number in the...